
from collections import deque

q = deque([1,2,3])
q.append(1)
q.popleft()

q.appendleft(1) #队首进队
q.pop()         #队尾出队
